*Replication file for Rikhil R. Bhavnani and Bethany Lacina, 2018, Nativism and Economic Integration across the Developing World, Cambridge University Press. Table 4 and Figure 4 & 5.

global controls 	DEprecip ldegrade lgdppercap lnatpopB lpurban lmschenroll lpm1524 

*Figure Four

twoway ///
(lpoly shsrunsh100 losmig_allB, lc(black) lpattern("dash_dot") lwidth(medthick)) ///
(lpoly shsvotesh100 losmig_allB, lc(black) lpattern("-")) ///
(lpoly shswinsh100 losmig_allB, lc(black) lpattern(solid)) , ///
legend(pos(6) col(1) ///
order(0 "Percentage of district:" 1 "Seats with Sena candidate" 2 "Votes won by Sena" 3 "Seats won by Sena"))  ///
title("") note("") ///
ylabel(,valuelabel labs(medium)) xlabel(,labsize(medium)) xtitle("{it:Ln} out-of-state migrants",size(medium)) ytitle("Percentage",size(medium))

*Figure 5

xi: ivreg2 lshsrunsh (losmig_allB=LPDW_ADEprecip) $controls i.district, cl(district) first
gen temp=1 if e(sample)
preserve
	keep if temp==1
	xi: reg losmig_allB $controls i.district, cl(district)
	predict losmig_allB_resid, resid
	xi: reg LPDW_ADEprecip $controls i.district, cl(district)
	predict LPDW_ADEprecip_resid, resid
	reg losmig_allB_resid LPDW_ADEprecip_resid
		
	twoway (scatter losmig_allB_resid LPDW_ADEprecip_resid) || (lfit losmig_allB_resid LPDW_ADEprecip_resid, lpattern(solid)), ytitle("{it:Ln} out-of-state migrants | X") xtitle("Abnormal monsoon instrument | X") legend(off)
	graph2tex, eps("$path\ShivSenaVotes\SenaTablesFigures\instrmh")
	
	corr losmig_allB_resid LPDW_ADEprecip_resid
	
restore

*Table 4

*Model 1

reg lshsrunsh losmig_allB

*Model 2

areg lshsrunsh losmig_allB $controls, a(district) cl(district)

*Model 3, Stage 1 and 2

xi: ivreg2 lshsrunsh (losmig_allB=LPDW_ADEprecip) $controls i.district, cl(district) ffirst

*Model 4, Stage 1 and 2

xi: ivreg2 lshsvote (losmig_allB=LPDW_ADEprecip) $controls i.district, cl(district) ffirst

*Model 5, Stage 1 and 2

xi: ivreg2 lshswin (losmig_allB=LPDW_ADEprecip) $controls i.district, cl(district) ffirst
